*****REPLICATION INSTRUCTIONS for Collet, "Waiting for the Real Dragon: How Globalization, Patriotism and Trust Inﬂuence Tolerance in Southeast Asia" *Asian Journal of Comparative Politics*.  (2017).

**NOTE: Use the correct path of the dataset location and dataset filename where necessary below before attempting to execute the file.

*1.  DOWNLOAD ASIA BAROMETER DATASETS FOR 2006, 2007 and 2008

*Approval is required from Asia Barometer - https://www.asiabarometer.org/data/abdl.php

copy <URL>

*2. CREATE POOLED DATASET FROM INDIVIDUAL YEAR SURVEY FILES

use "/Users/~/Desktop/~AsiaBarometer2006_0929.dta"
*A.  Thin out original datafiles to essential variables
keep RunNo Country Q50b Q27_1 F1 F2group F3group F8group F9 Q11 Q43_2 Q44_1 Q44_2 Q44_3 Q44_4 Q44_5 Q44_6 Q44_7 Q44_7 Q44_8 Q44_9 Q44_10 Q44_11 Q23 Q18 Q20 Q34i Q29a Q29b Q29c Q29d Q29e Q29f Q29g Q29h Q29i Q29j Q29k Q29l Q29m Q29n Q29o Q3_1 Q3_2 Q3_3 Q3_4 Q3_5 Q3_6 
*B.  Save subset in another folder
mkdir AB_pooled
save "AB_pooled/ab2006_subset.dta", replace

gen study = .
mvencode study, mv(2006)
order study, first

rename Q50b tol_gay
rename Q27_1 wom_equal
rename F1 gender
rename F2group age
rename F3group educ
rename F8group income
rename F9 religion
rename Q11 pers_trust
rename Q43_2 fam_struc
rename Q44_1 kids_ind
rename Q44_2 kids_dil
rename Q44_3 kids_hon
rename Q44_4 kids_sin
rename Q44_5 kids_mnd
rename Q44_6 kids_hum
rename Q44_7 kids_rel
rename Q44_8 kids_pat
rename Q44_9 kids_comp
rename Q44_10 kids_rspeld
rename Q44_11 kids_deftch
rename Q23 religiosity
rename Q18 pride
rename Q20 anthem
rename Q34i pated
rename Q29a trust_centgov
rename Q29b trust_locgov
rename Q29c trust_army
rename Q29d trust_legal
rename Q29e trust_police
rename Q29f trust_parlia
rename Q29g trust_party
rename Q29h trust_pubeduc
rename Q29i trust_pubhealth
rename Q29j trust_domcomp
rename Q29k trust_intcomp
rename Q29l trust_unions
rename Q29m trust_media
rename Q29n trust_ngos
rename Q29o trust_relig
rename Q3_1 glob_rellive
rename Q3_2 glob_travabr
rename Q3_3 glob_friends
rename Q3_4 glob_forgntv
rename Q3_5 glob_webemail
rename Q3_6 glob_jobcont

save "AB_pooled/ab2006_subset.dta", replace
***
use "/Users/~/Desktop/~/AsiaBarometer2007_070911.dta"

keep RunNo Country Q50b Q28_1 F1 F2group F3group F8group F9 Q12 Q43_2 Q44_1 Q44_2 Q44_3 Q44_4 Q44_5 Q44_6 Q44_7 Q44_7 Q44_8 Q44_9 Q44_10 Q44_11 Q24 Q19 Q21 Q35i Q30a Q30b Q30c Q30d Q30e Q30f Q30g Q30h Q30i Q30j Q30k Q30l Q30m Q30n Q30o Q3_1 Q3_2 Q3_3 Q3_4 Q3_5 Q3_6 weigh
save "AB_pooled/ab2007_subset.dta", replace

gen study = .
mvencode study, mv(2007)
order study, first


rename RunNo id
rename Q50b tol_gay
rename Q28_1 wom_equal
rename F1 gender
rename F2group age
rename F3group educ
rename F8group income
rename F9 religion
rename Q12 pers_trust
rename Q43_2 fam_struc
rename Q44_1 kids_ind
rename Q44_2 kids_dil
rename Q44_3 kids_hon
rename Q44_4 kids_sin
rename Q44_5 kids_mnd
rename Q44_6 kids_hum
rename Q44_7 kids_rel
rename Q44_8 kids_pat
rename Q44_9 kids_comp
rename Q44_10 kids_rspeld
rename Q44_11 kids_deftch
rename Q24 religiosity
rename Q19 pride
rename Q21 anthem
rename Q35i pated
rename Q30a trust_centgov
rename Q30b trust_locgov
rename Q30c trust_army
rename Q30d trust_legal
rename Q30e trust_police
rename Q30f trust_parlia
rename Q30g trust_party
rename Q30h trust_pubeduc
rename Q30i trust_pubhealth
rename Q30j trust_domcomp
rename Q30k trust_intcomp
rename Q30l trust_unions
rename Q30m trust_media
rename Q30n trust_ngos
rename Q30o trust_relig
rename Q3_1 glob_rellive
rename Q3_2 glob_travabr
rename Q3_3 glob_friends
rename Q3_4 glob_forgntv
rename Q3_5 glob_webemail
rename Q3_6 glob_jobcont
rename weigh psweight

save "AB_pooled/ab2007_subset.dta", replace

use "/Users/~/Desktop/~/AsiaBarometer2008_0902.dta"
keep idno Country Q54b Q29_1 F1 F2group F3group F8group F9 Q12 Q47_2 Q48_1 Q48_2 Q48_3 Q48_4 Q48_5 Q48_6 Q48_7 Q48_8 Q48_9 Q48_10 Q48_11 Q25 Q19 Q22 Q36i Q31a Q31b Q31c Q31d Q31e Q31f Q31g Q31h Q31i Q31j Q31k Q31l Q31m Q31n Q31o Q3_1 Q3_2 Q3_3 Q3_4 Q3_5 Q3_6 weigh
save "AB_pooled/ab2008_subset.dta", replace

gen study = .
mvencode study, mv(2008)
order study, first

*Some country codes overlap between the datafiles.  The variable needs to be recoded.

recode Country (1=76) (7=77) (61=61) (81=3) (86=1) (91=91)
lab def country 76 "United States" 77 "Russia"

rename idno id
rename Q54b tol_gay
rename Q29_1 wom_equal
rename F1 gender
rename F2group age
rename F3group educ
rename F8group income
rename F9 religion
rename Q12 pers_trust
rename Q47_2 fam_struc
rename Q48_1 kids_ind
rename Q48_2 kids_dil
rename Q48_3 kids_hon
rename Q48_4 kids_sin
rename Q48_5 kids_mnd
rename Q48_6 kids_hum
rename Q48_7 kids_rel
rename Q48_8 kids_pat
rename Q48_9 kids_comp
rename Q48_10 kids_rspeld
rename Q48_11 kids_deftch
rename Q25 religiosity
rename Q19 pride
rename Q22 anthem
rename Q36i pated
rename Q31a trust_centgov
rename Q31b trust_locgov
rename Q31c trust_army
rename Q31d trust_legal
rename Q31e trust_police
rename Q31f trust_parlia
rename Q31g trust_party
rename Q31h trust_pubeduc
rename Q31i trust_pubhealth
rename Q31j trust_domcomp
rename Q31k trust_intcomp
rename Q31l trust_unions
rename Q31m trust_media
rename Q31n trust_ngos
rename Q31o trust_relig
rename Q3_1 glob_rellive
rename Q3_2 glob_travabr
rename Q3_3 glob_friends
rename Q3_4 glob_forgntv
rename Q3_5 glob_webemail
rename Q3_6 glob_jobcont
rename weigh psweight
save "AB_pooled/ab2008_subset.dta", replace

*Appending three datafiles
use "AB_pooled/ab2006_subset.dta"
append using "/Users/~/Desktop/~/AB_pooled/ab2007_subset.dta" "/Users/~/Desktop/~/AB_pooled/ab2008_subset.dta"
save "AB_pooled/ab20062008_pooled.dta", replace

**In the pooled data (AB_pooled/ab20062008_pooled.dta), new variable labels need to be created to account for changes made in the 2008 file.

rename Country country
label drop COUNTRY
label define country 1 "China" 2 "Hong Kong" 3 "Japan" 4 "Korea" 5 "Singapore" 6 "Taiwan" 7 "Vietnam" 60 "Malaysia" 61 "Australia" 62 "Indonesia" 63 "Philippines" 66 "Thailand" 76 "United States" 77 "Russia" 91 "India" 95 "Myanmar" 855 "Cambodia" 856 "Laos" 
label values country country

***B.  CREATE NEW VARIABLES 
**Civilizational groupings

generate sinic = 1 if country==5
replace sinic = 1 if country==7
replace sinic = 1 if country==856
mvencode sinic, mv(0)
label define sinic 0 "Not Sinic" 1 "Sinic"
label values sinic sinic

generate indic = 1 if country==60
replace indic = 1 if country==62
replace indic = 1 if country==63
replace indic = 1 if country==66
replace indic = 1 if country==855
mvencode indic, mv(0)
label define indic 0 "Not Indic" 1 "Indic"
label values indic indic

generate west = 1 if country==61
replace west = 1 if country==76
mvencode west, mv(0)
label define west 0 "Not West" 1 "West"
label values west west

generate civiz = 1 if sinic==1
replace civiz = 2 if indic==1
replace civiz = 3 if west==1
mvencode civiz, mv(0)
label define civiz 0 "Other" 1 "Sinic" 2 "Indic" 3 "West"
label values civiz civiz

**Southeast Asia variable

generate sea = 1 if country==5
replace sea = 1 if country==7
replace sea = 1 if country==60
replace sea = 1 if country==62
replace sea = 1 if country==63
replace sea = 1 if country==66
replace sea = 1 if country==95
replace sea = 1 if country==855
replace sea = 1 if country==856
mvencode sea, mv(0)
label define sea 0 "Not ASEAN" 1 "ASEAN"
label values sea sea

**OPTION: drop Myanmar cases
drop if country==95

***C.  RECODE VARIABLES
*replace missing values to count as dont knows

mvencode educ income religiosity, mv(9)

**Household structure --> single

recode fam_struc (1=1) (else=0), gen(single)
label define single 1 "Single" 0 "Not Single"
label values single single

**Gender

recode gender (1=0) (2=1), gen(female)
label define female 1 "Female" 0 "Male"
label values female female

**Religion

recode religion (1/2=1) (3/4=2) (5=3) (6/7=4) (8=5) (10=5) (11=5) (12=5) (13/14=6) (99=6) (.=6) (9=7), gen(relig_re)
lab define relig_re 1 "Catholic or Other Christian" 2 "Muslim" 3 "Hindu" 4 "Buddhist" 5 "Other" 6 "None" 7 "Jewish"
lab val relig_re relig_re

**Values -- see below

**Foreign Exposure Index (FEI)*
generate forexpind = glob_rellive + glob_travabr + glob_friends + glob_forgntv + glob_webemail + glob_jobcont

**Patriotism Index (PI)*
recode pride (1/2=1) (else=0), gen(pride_i)
recode anthem (1=1) (else=0), gen(anthem_i)
recode pated (1/2=1) (else=0), gen(pated_i)
generate patind = pride_i + anthem_i + pated_i

**
recode trust_centgov trust_locgov trust_army trust_legal trust_police trust_parlia trust_party trust_pubeduc trust_pubhealth trust_domcomp trust_intcomp trust_unions trust_media trust_ngos trust_relig (1/2=1) (else=0), gen (trust_centgov_i trust_locgov_i trust_army_i trust_legal_i trust_police_i trust_parlia_i trust_party_i trust_pubeduc_i trust_pubhealth_i trust_domcomp_i trust_intcomp_i trust_unions_i trust_media_i trust_ngos_i trust_relig_i)

**Trust - Civil Society
generate trustind_civil = trust_domcomp_i + trust_intcomp_i + trust_unions_i + trust_media_i + trust_ngos_i + trust_relig_i

**WEIGHTS: Design weight standardize to N=1,000
generate dweight = 1/1.038 if country==5
replace dweight = 1/1.012 if country==855
replace dweight = 1/1.052 if country==91
mvencode dweight, mv(1)

***D.  SET FOR SURVEY DATA ANALYSIS
svyset [pweight=dweight]

*================================================================
****3.  GENERATE TABLES AND FIGURES

**Secondary run of Geddes et al regimes data
**Table made available as supplement file: Geddes_regimes_table.csv

**Figure 1.  The Relationship Between Empowerment Rights, Women’s Representation and Gay Rights in Southeast Asia.
**Raw data for replication made available as supplement file: Collet_AJCP_Fig1_data.csv

**Fig plotted with Datagraph - http://www.visualdatatools.com/DataGraph/

*OPTION: log results as text file
log using "/Users/~/Desktop/Collet_AJCP_replication/AB_pooled/results.log"

**Figure 2. Justification of Homosexuality by Support for Gender Equality in Southeast Asia, Australia and the United States (weighted by Foreign Exposure Index).

by country, sort: means tol_gay
by civiz, sort: means tol_gay
by country, sort: means wom_equal
by civiz, sort: means wom_equal

**Fig plotted with Datagraph - http://www.visualdatatools.com/DataGraph/

**Appendix 1. Values: Means, Varimax Rotated Factor Loadings, Unique Variances and Revised Constructs.

quietly: factor kids_ind kids_dil kids_hon kids_sin kids_mnd kids_hum kids_rel kids_pat kids_comp kids_rspeld kids_deftch if sea==1 & sinic==1, factors(2) pcf
rotate, varimax horst
predict factor1_sinic_respdef factor2_sinic_indcomp

quietly: factor kids_ind kids_dil kids_hon kids_sin kids_mnd kids_hum kids_rel kids_pat kids_comp kids_rspeld kids_deftch if sea==1 & indic==1, factors(2) pcf
rotate, varimax horst
predict factor1_indic_dilpat factor2_indic_respdef

quietly: factor kids_ind kids_dil kids_hon kids_sin kids_mnd kids_hum kids_rel kids_pat kids_comp kids_rspeld kids_deftch if west==1, factors(2) pcf
rotate, varimax horst
predict factor1_west_pathumb factor2_west_dilcomp

**Appendix 2: Descriptive Statistics, by Sub-Region

by civiz, sort: summarize tol_gay wom_equal factor1_sinic_respdef factor2_sinic_indcomp factor1_indic_dilpat factor2_indic_respdef factor1_west_pathumb factor2_west_dilcomp forexpind patind trust_centgov_i trustind_civil age educ income female single relig_re religiosity

**Table 1: GLM Estimates for Justification of Homosexuality, by Sub-Region

quietly svy: glm tol_gay ib5.age ib1.educ ib1.income female single i.religiosity ib4.relig_re i.country if sea==1 & sinic==1, family(ig) link(log)
estimates store sinic_g_soc
quietly svy: glm tol_gay  ib5.age ib1.educ ib1.income female single i.religiosity ib4.relig_re i.country if sea==1 & indic==1, family(ig) link(log)
estimates store indic_g_soc
quietly svy: glm tol_gay  ib5.age ib1.educ ib1.income female single i.religiosity ib1.relig_re i.country if west==1, family(ig) link(log)
estimates store west_g_soc
**to produce Table 2
estout sinic_g_soc indic_g_soc west_g_soc, cells("b se p") stats(N) label

**Direct test of FEI on values--in text, no table
*Sinic models
svy: regress factor1_sinic_respdef forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re if sea==1 & sinic==1
svy: regress factor2_sinic_indcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re if sea==1 & sinic==1
*Sinic: with country control
svy: regress factor1_sinic_respdef forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & sinic==1
svy: regress factor2_sinic_indcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & sinic==1
*Indic models
svy: regress factor1_indic_dilpat forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re if sea==1 & indic==1
svy: regress factor2_indic_respdef forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re if sea==1 & indic==1
*Indic: with country control
svy: regress factor1_indic_dilpat forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & indic==1
svy: regress factor2_indic_respdef forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & indic==1
*West models
svy: regress factor1_west_pathumb forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re if west==1
svy: regress factor2_west_dilcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re if west==1
*West: with country control
svy: regress factor1_west_pathumb forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if west==1
svy: regress factor2_west_dilcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if west==1

**Table 2: Estimates for Foreign Exposure Index (FEI) and Values on Justification of Homosexuality and Gender Equality.

quietly svy: glm tol_gay factor1_sinic_respdef c.factor1_sinic_respdef#c.forexpind forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & sinic==1, family(ig) link(log)
estimates store sinic_g_fei_f1

quietly svy: glm tol_gay factor2_sinic_indcomp c.factor2_sinic_indcomp#c.forexpind forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & sinic==1, family(ig) link(log)
estimates store sinic_g_fei_f2

**to produce a table similar to Tab 2 use 'esttab' from stored estimates

esttab sinic_g_fei_f1 sinic_g_fei_f2, keep(forexpind factor1_sinic_respdef factor2_sinic_indcomp c.factor1_sinic_respdef#c.forexpind c.factor2_sinic_indcomp#c.forexpind) cells("b se p") stats(N) 

esttab sinic_w_fei_f1 sinic_w_fei_f2, keep(forexpind factor1_sinic_respdef factor2_sinic_indcomp c.factor1_sinic_respdef#c.forexpind c.factor2_sinic_indcomp#c.forexpind) cells("b se p") stats(N) 

*Indic models

quietly svy: glm tol_gay factor1_indic_dilpat c.factor1_indic_dilpat#c.forexpind forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & indic==1, family(ig) link(log)
estimates store indic_g_fei_f1

quietly svy: glm tol_gay factor2_indic_respdef c.factor2_indic_respdef#c.forexpind forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & indic==1, family(ig) link(log)
estimates store indic_g_fei_f2

**to produce a table similar to Tab 2 use 'esttab' from stored estimates

esttab indic_g_fei_f1 indic_g_fei_f2, keep(forexpind factor1_indic_dilpat factor2_indic_respdef c.factor1_indic_dilpat#c.forexpind c.factor2_indic_respdef#c.forexpind) cells("b se p") stats(N) 

esttab indic_w_fei_f1 indic_w_fei_f2, keep(forexpind factor1_indic_dilpat  factor2_indic_respdef c.factor1_indic_dilpat#c.forexpind c.factor2_indic_respdef#c.forexpind) cells("b se p") stats(N) 

*West models

quietly svy: glm tol_gay factor1_west_pathumb c.factor1_west_pathumb#c.forexpind forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if west==1, family(ig) link(log)
estimates store west_g_fei_f1

quietly svy: glm tol_gay factor2_west_dilcomp c.factor2_west_dilcomp#c.forexpind forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if west==1, family(ig) link(log)
estimates store west_g_fei_f2

**to produce a table similar to Tab 2 use 'esttab' from stored estimates

esttab west_g_fei_f1 west_g_fei_f2, keep(forexpind factor1_west_pathumb factor2_west_dilcomp c.factor1_west_pathumb#c.forexpind c.factor2_west_dilcomp#c.forexpind) cells("b se p") stats(N) 

esttab west_w_fei_f1 west_w_fei_f2, keep(forexpind factor1_west_pathumb factor2_west_dilcomp c.factor1_west_pathumb#c.forexpind c.factor2_west_dilcomp#c.forexpind) cells("b se p") stats(N) 

*Table 3: Estimates for Allegiance Measures on Justification of Homosexuality and Gender Equality, by Sub-Region.

*Sinic models

quietly: svy: glm tol_gay patind factor1_sinic_respdef factor2_sinic_indcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & sinic==1, family(ig) link(log)
estimates store sinic_g_patind

quietly: svy: glm tol_gay trustind_civil factor1_sinic_respdef factor2_sinic_indcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & sinic==1, family(ig) link(log)
estimates store sinic_g_trustciv

*to produce a table similar to Tab 5 use 'esttab' from stored estimates
esttab sinic_g_patind sinic_w_patind sinic_g_trustciv sinic_w_trustciv, keep(patind trustind_civil) cells("b se p") stats(N)

*Indic models

quietly: svy: glm tol_gay patind factor1_indic_dilpat  factor2_indic_respdef forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & indic==1, family(ig) link(log)
estimates store indic_g_patind

quietly: svy: glm tol_gay trustind_civil factor1_indic_dilpat  factor2_indic_respdef forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & indic==1, family(ig) link(log)
estimates store indic_g_trustciv

quietly: svy: glm tol_gay trust_centgov_i factor1_indic_dilpat factor2_indic_respdef forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if sea==1 & indic==1, family(ig) link(log)
estimates store indic_g_trustcentgov

*to produce a table similar to Tab 3 use 'esttab' from stored estimates

esttab indic_g_patind indic_g_trustciv indic_g_trustcentgov indic_w_patind indic_w_trustciv indic_w_trustcentgov, keep(patind trustind_civil trust_centgov_i) cells("b se p") stats(N)

*West
quietly: svy: glm tol_gay patind factor1_west_pathumb factor2_west_dilcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if west==1, family(ig) link(log)
estimates store west_g_patind

quietly: svy: glm tol_gay trustind_civil factor1_west_pathumb factor2_west_dilcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if west==1, family(ig) link(log)
estimates store west_g_trustciv

quietly: svy: glm tol_gay trust_centgov_i factor1_west_pathumb factor2_west_dilcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re i.country if west==1, family(ig) link(log)
estimates store west_g_trustcentgov

*to produce a table similar to Tab 3 use 'esttab' from stored estimates

esttab west_g_patind west_g_trustciv west_g_trustcentgov west_w_patind west_w_trustciv west_w_trustcentgov, keep(patind trust_centgov_i trustind_civil) cells("b se p") stats(N)

**Table 4: GLM Estimates and Marginal Effects of Gender Equality and Select Factors on Justification of Homosexuality Scores.

*Sinic
svy: glm tol_gay wom_equal patind trustind_civil factor1_sinic_respdef factor2_sinic_indcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib4.relig_re i.country if sea==1 & sinic==1, family(ig) link(log)
mchange age educ income female single, statistics(all) 
mchange relig_re religiosity, statistics(all)
mchange forexpind factor1_sinic_respdef factor2_sinic_indcomp wom_equal patind trustind_civil, statistics(all)

*Indic
svy: glm tol_gay wom_equal patind trustind_civil factor1_indic_dilpat factor2_indic_respdef forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib4.relig_re i.country if sea==1 & indic==1, family(ig) link(log)
mchange age educ income female single, statistics(all) 
mchange relig_re religiosity, statistics(all)
mchange forexpind factor1_indic_dilpat  factor2_indic_respdef wom_equal patind trustind_civil, statistics(all)

*West
svy: glm tol_gay wom_equal patind trustind_civil factor1_west_pathumb factor2_west_dilcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib1.relig_re i.country if west==1, family(ig) link(log)
mchange age educ income female single, statistics(all) 
mchange relig_re religiosity, statistics(all)
mchange forexpind factor1_west_pathumb factor2_west_dilcomp wom_equal patind trustind_civil, statistics(all)

*Figure 3: 

quietly: svy: glm tol_gay wom_equal patind trustind_civil factor1_sinic_respdef factor2_sinic_indcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib4.relig_re i.country if sea==1 & sinic==1, family(ig) link(log)
margins, dydx(age) at(forexpind=(0(1)6))

quietly: svy: glm tol_gay wom_equal patind trustind_civil factor1_indic_dilpat factor2_indic_respdef forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib4.relig_re i.country if sea==1 & indic==1, family(ig) link(log)
margins, dydx(age) at(forexpind=(0(1)6))

quietly: svy: glm tol_gay wom_equal patind trustind_civil factor1_west_pathumb factor2_west_dilcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib1.relig_re i.country if west==1, family(ig) link(log)
margins, dydx(age) at(forexpind=(0(1)6))

*Figure 4: Marginal Eﬀects of Patriotism and Trust in Civil Society on Justiﬁcation of Homosexuality, by Age.

quietly: svy: glm tol_gay wom_equal patind trustind_civil factor1_sinic_respdef factor2_sinic_indcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib4.relig_re i.country if sea==1 & sinic==1, family(ig) link(log)
margins, dydx(age) at(patind=(0(1)3))
margins, dydx(age) at(trustind_civil=(0(1)6))

quietly: svy: glm tol_gay wom_equal patind trustind_civil factor1_indic_dilpat factor2_indic_respdef forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib4.relig_re i.country if sea==1 & indic==1, family(ig) link(log)
margins, dydx(age) at(patind=(0(1)3))
margins, dydx(age) at(trustind_civil=(0(1)6))

quietly: svy: glm tol_gay wom_equal patind trustind_civil factor1_west_pathumb factor2_west_dilcomp forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib1.relig_re i.country if west==1, family(ig) link(log)
margins, dydx(age) at(patind=(0(1)3))
margins, dydx(age) at(trustind_civil=(0(1)6))


**EXTRA: Claims made in Conclusion
*Thai public more amenable to global exposure**
svy: glm tol_gay forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re if country==66, family(ig) link(log)
svy: probit wom_equal forexpind ib5.age ib1.educ ib1.income female single i.religiosity ib6.relig_re if country==66

*OPTION: Close log file
log close
